const cockpit = {
  namespaced: true,

  state: {
    areaInfo: [],

    personInfo: [], // 人员卡信息

    carInfo: [] // 车辆卡信息,
  },

  getters: {
    areaStatList(state) {
      return state.areaInfo
        .map((item) => ({
          boundary: item.fenceCoordinates,
          areaId: item.areaId
        }))
        .filter((item) => item.boundary)
    },
    onLinePersonList(state) {
      return state.personInfo
    },
    onLineCarList(state) {
      return state.carInfo
    }
  },

  mutations: {
    setAreaInfo(state, data) {
      state.areaInfo = data
    },

    setCardInfo(state, list = []) {
      state.personInfo = list.filter((item) => item.id?.includes('person-'))

      state.carInfo = list.filter((item) => item.id?.includes('car-'))
    }
  },

  actions: {}
}

export default cockpit
